package com.mew.chess.core.game.lh.game.common;


import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 牌类型
 */
public enum CardType {

    Spade(1, "黑桃"),
    Diamond(2, "方块"),
    Club(3, "梅花"),
    Hart(4, "红桃"),

    JokerSmall(5, "小王"),
    JokerBig(6, "大王");

    private final int code;
    private final String desc;

    private CardType(final int code, final String desc) {
        this.code = code;
        this.desc = desc;
    }

    private final static Map<Integer, CardType> stateMap
            = Arrays.stream(CardType.values()).collect(Collectors.toMap(CardType::code, code -> code));


    public int code() {
        return this.code;
    }

    public String desc() {
        return this.desc;
    }

    /**
     * @param code 代码
     * @return 转换出来的状态码
     */
    public static CardType parse(int code) {
        return stateMap.get(code);
    }


}
